/**
 * 
 */
package com.java.test.user.mapper;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.java.test.user.dto.MemberSliceInfo;

/**
 * @author Administrator
 *
 */
@Component
public class MemberSliceMapper {
	@Autowired
	private JdbcTemplate jdbcTemplate;

	public List<MemberSliceInfo> selectMemberSliceList() {
		String sql = "select * from member_member_slice";
		List<MemberSliceInfo> list = jdbcTemplate.query(sql, new MemberSliceInfo());
		return list;
	}

	public int insertMemberSlice(MemberSliceInfo info) {
		String sql = "insert into member_member_slice(slice_name,content,count)values(?,?,?)";
		int i = jdbcTemplate.update(sql, info.getSliceName(),info.getContent(),info.getCount());
		return i;
	}

	public MemberSliceInfo selectById(int id) {
		String sql = "select * from member_member_slice where id=?";
		MemberSliceInfo info = jdbcTemplate.queryForObject(sql, new MemberSliceInfo(), id);
		return info;
	}

	public int updateMemberSliceById(MemberSliceInfo info) {
		String sql = "update member_member_slice set slice_name =?,content=?,count=? where id=?";
		int i = jdbcTemplate.update(sql, info.getSliceName(),info.getContent(),info.getCount(),info.getId());
		return i;
	}

}
